You can produce a system alert sound to catch the user's attention by calling the SysBeep procedure. The SysBeep procedure is a Sound Manager routine that plays the alert sound selected by the user in the Alert Sounds control panel. Here's an example of calling SysBeep :
IF myErr <> noErr THEN
SysBeep(30);
You must supply a parameter when you call the SysBeep procedure, even though the Sound Manager ignores that parameter in most cases. All system alert sounds are stored as format 1 'snd ' resources in the System file and are played by the Sound Manager. There is one instance in which the number passed to SysBeep is not ignored: if the user has selected the Simple Beep as the system alert sound on some Macintosh computers (for example, a Macintosh Plus or Macintosh SE), the beep is generated by code stored in ROM rather than by the Sound Manager, and the duration parameter is interpreted in ticks (sixtieths of a second).
The SysBeep procedure has no effect if an application has disabled the system alert sound. You might do this to prevent the system alert sound from interrupting some other sound. For information on enabling and disabling the system alert sound, see the chapter "Sound Manager" in this book.
You should not call the SysBeep procedure at interrupt time, because doing so causes the Sound Manager to attempt to allocate memory and load a resource.
If your primary use of the SysBeep procedure is to alert the user of important or abnormal occurrences, it might be preferable to use the Notification Manager. See the chapter "Notification Manager" in Inside Macintosh: Processes for complete details on alerting the user.
| Previous | Chapter contents | Chapter top | Section top | Next |